<template>
  <h2>测试八，toRef()对象外部引入</h2>
  <p>
    {{ name }}--{{ age }}:{{ salary }}
  </p>
  <button @click="name+='!'">改名</button>
  <button @click="age++">过生日</button>
  <button @click="salary+=1000">涨工资</button>
</template>

<script>
import Teacher from "../entity/Teacher";
import {toRef} from "vue";

export default {
  name: "TeacherTest",
  setup() {
    const teacher = Teacher('yangtao', 34, 20000)
    return {
      // 单独写法
      name: toRef(teacher, "name"),
      age: toRef(teacher, "age"),
      salary: toRef(teacher.job, "salary")

    }
  }
}
</script>